



ac.game:event '商店-清空装备'(function(_,unit)
    --删除原本的
    local list = unit:get_data('商店物品') or {}
    for _,skill in ipairs(list) do
        skill:remove()
    end
end)

ac.game:event '单位-刷新装备'(function(_,unit,level)
    if level then
        unit:set_data('刷新次数',0)
        unit:set_data('刷新等级',level)
    else
        unit:set_data('刷新次数',unit:get_data('刷新次数',0) + 1)
    end
    local level = level or unit:get('刷新等级')

    --删除原本的
    unit:notify('商店-清空装备',unit)
    
    --添加新的
    local num = 4
    local list = {}
    for a=1,num do
        local skill = unit:add_skill('购买商店装备','英雄',a)
        list[a] = skill
    end
    unit:set_data('商店物品',list)

end)




ac.skill('购买商店装备'){
    keep_cool = false,
    hotkey = '',
    on_add = function(self)
        local unit = self.owner
        local temp,index = table.random(unit.fw_list)
        local name = temp.name
        local item = ac.item.new(name)
        self.temp_data = item
        self:set_art(item.art)
        self.title = item.title or name
        self.tip = format_obj(item,item.shop_tip or item.tip)
        self.show_cd_num = item.show_cd_num
        self.exiocn = item.exiocn
    end,

    on_sell = function(self,hero,player)
        local unit = self.owner
        local hero = player.hero
        local temp = self.temp_data
        local item = ac.item.create(temp.name,nil,temp:copy_info())
        
        unit:notify('商店-清空装备',unit)
        show_skill_tip(player,self,'刷新')
        player_add_item(player,item)
    end
}


ac.skill('抽取装备'){
    title = '抽取初级装备',
    item_level = 1,
    cool = 1,
    get_lum = function()
        return 100
    end,
    on_sell = function(self,hero,player)
        local unit = self.owner
        unit:notify('单位-刷新装备',unit,self.item_level)
    end
}



ac.skill('抽取装备设置'){
    on_add = function(self)
        self:remove()
        local unit = self.owner
        
        unit.fw_list = get_fw_list()
        unit:add_skill('抽取装备','英雄',9)
        
        unit:event '商店-显示'(function(trg,unit)
            local player = unit.owner
            trg:remove()
            player:add('木材',100)
        end)
    end
}
